﻿//***********************************************************************************//
// Autor:  			Adrian Di Puglia      						     				*//
//***********************************************************************************//
//  Date Picker y File Path Cleaner                                                 *//
// _________________________________________________________________________________*//

$(function () {
    $('.date-pick').datePicker({ autoFocusNextInput: true });
});

function fileUpload(uFile) {
    var fullPath = uFile.value;
    var startIndex = (fullPath.indexOf('\\') >= 0 ? fullPath.lastIndexOf('\\') : fullPath.lastIndexOf('/'));
    var filename = fullPath.substring(startIndex);
    if (filename.indexOf('\\') === 0 || filename.indexOf('/') === 0) {
        filename = filename.substring(1);
    }
    document.getElementById("Problemario_file_name").value = filename;
}

function autoDropdownList(opc) {
    if (opc.value == 1) {
        //$('#idRol').val("ALL");
        document.getElementById("text_step").innerHTML = "1"
        document.getElementById('idRol').value = "ALL";
    } else {
        //$('#idRol').val("Guest_C");
        document.getElementById("text_step").innerHTML = "3"
        document.getElementById('idRol').value = "Guest_C";
    }

}


var submitted = false;
var cleaned = false;

$(document).ready(function () {
    window.onbeforeunload = function (e) {
        if (!submitted && !cleaned) {
            var message = ">>>>>ADVERTENCIA<<<<<<<< \n\n VERIFIQUE el COMPLETADO de los 3 Pasos de CARGA del PROBLEMARIO, si Seleccionó SEGUNDA Etapa.", e = e || window.event;
            if (e) {
                e.returnValue = message;
            }
            return message;
        }
    }

    $("form").submit(function () {
        submitted = true;
        cleaned = true;
    });

    document.getElementsByTagName("button")[0].onclick = function (e) {
        submitted = true;
        cleaned = true;
        //window.location.href = window.location.href
        window.location.assign(window.location.href);
    };

});